function editWord(data, index) {
    layui.use(['upload', 'form', 'laydate'], function () { //此段代码必不可少
        var form = layui.form;
        var upload = layui.upload;
        var laydate = layui.laydate;
        if (data == "") {
            //将按钮改成添加
            $("#update").html("发布");
            $("#update").click(function () {
                    let english = $("#english").val();
                    let chinese = $("#chinese").val();
                    if (english == '') {
                        layer.msg("英文释义不能为空", function () {
                            $("#english").focus();
                        })
                    } else if (english != '') {
                        if (chinese == '') {
                            layer.msg("中文释义不能为空", function () {
                                $("#chinese").focus();
                            })
                        } else {
                            let userInfo = JSON.parse(sessionStorage.getItem("userInfo"));
                            let author = "";
                            if (userInfo.name != null)
                                author = userInfo.name;
                            else
                                author = userInfo.code;
                            let wordData = {
                                "english": english,
                                "chinese": chinese,
                                "author": author,
                                "user": userInfo.code
                            }
                            let result = ajaxModel("/words/words/addWords", "post", wordData);
                            console.log(result);
                            if (result.code == 200) {
                                layer.alert(result.message, {icon: 1}, function () {
                                    parent.location.reload();
                                    parent.layer.close(index);
                                });
                            } else
                                layer.alert(result.message, {icon: 1});
                        }
                    }
                }
            );
            $("#cancel").click(function () {
                parent.layer.close(index);
            });
        } else {
            data = JSON.parse(data);
            $("#english").val(data.english);
            $("#chinese").val(data.chinese);
            $("#update").click(function () {
                    let english = $("#english").val();
                    let chinese = $("#chinese").val();
                    if (english == '') {
                        layer.msg("英文释义不能为空", function () {
                            $("#english").focus();
                        })
                    } else if (english != '') {
                        if (chinese == '') {
                            layer.msg("中文释义不能为空", function () {
                                $("#chinese").focus();
                            })
                        } else {
                            let wordData = {
                                "id": data.id,
                                "english": english,
                                "chinese": chinese
                            }
                            let result = ajaxModel("/words/words/editWords", "post", wordData);
                            console.log(result);
                            if (result.code == 200) {
                                layer.alert(result.message, {icon: 1}, function () {
                                    parent.location.reload();
                                    layer.close(index);
                                });
                            } else
                                layer.alert(result.message, {icon: 1});
                        }
                    }
                }
            );
            $("#cancel").click(function () {
                parent.layer.close(index);
            });
            form.render();
        }
    });
}